package uc;

import co.chuangdian.oflauncher.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

@SuppressLint("Recycle")
public class SubTitleView extends LinearLayout {
	TextView titleTextView, subtitleTextView;

	public SubTitleView(Context context, AttributeSet attrs) {
		super(context, attrs);
		View.inflate(getContext(), R.layout.uc_subtitleview, this);
		this.setOrientation(LinearLayout.VERTICAL);
		titleTextView = (TextView) this.findViewById(R.id.titleTextView);
		subtitleTextView = (TextView) this.findViewById(R.id.subtitleTextView);
		//
		TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.of);
		int count = typedArray.getIndexCount();
		for (int i = 0; i < count; i++) {
			int index = typedArray.getIndex(i);
			switch (index) {
			case R.styleable.of_title:
				setTitle(typedArray.getString(index));
				break;
			case R.styleable.of_subtitle:
				setSubtitle(typedArray.getString(index));
				break;
			default:
				break;
			}
		}
	}

	public String getTitle() {
		return (String) titleTextView.getText();
	}

	public void setTitle(String title) {
		titleTextView.setText(title);
	}

	public String getSubtitle() {
		return (String) subtitleTextView.getText();
	}

	public void setSubtitle(String subtitle) {
		subtitleTextView.setText(subtitle);
	}
}
